#include <stdio.h>
#include <stdint.h>
#include <pthread.h>

void UtilThreadNew(void *obj, void *(callback)(void*))
{
    pthread_t th;
    pthread_attr_t attr;
    int32_t ret;
    //禁用线程同步,线程运行结束后自动释放
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    //抛出线程
    ret = pthread_create(&th, &attr, callback, (void *)obj);
    if (ret != 0)
        fprintf(stderr, "%s(%d): pthread_create failed !!\r\n", __FUNCTION__, __LINE__);
    //attr destroy
    pthread_attr_destroy(&attr);
}
